#include<bits/stdc++.h>
using namespace std;

class Solution {
public:
    int findNthDigit(int n) {
        int num = 1; 
        long long base = 9;
        while(n > num * base){
            n -= num * base;
            num++;
            base *= 10;
        }
        n--;
        int offset = n / num;
        int begin = 1;
        for(int i = 0; i < num - 1; i++){
            begin *= 10;
        }
        int mod = n % num;
        string ans = to_string(offset + begin);
        return ans[mod] - '0';
    }
};

/**
 * 2021.11.30 
 * 找规律，模拟 
 */

